<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- header -->
    <%@ include file="/WEB-INF/views/include/header.jsp" %>
    <%--多附件上传css--%>
    <link rel="stylesheet" href="<s:url value="/assets/css/main.css"></s:url>"/>
    <style>
        body{
            background: #fff;
        }
        body.dragging, body.dragging * {
            cursor: move !important;
        }
        .dragged {
            position: absolute;
            opacity: 0.5;
            z-index: 2000;
        }
        #example li.placeholder {
            position: relative;
            /** More li styles **/
        }
        #example li.placeholder:before {
            position: absolute;
            /** Define arrowhead **/
        }
        .bottons {
            width: 400px;
            height: 30px;
            line-height: 30px;
            text-align: center;
            border-bottom: 1px solid #333;
            display: flex;
            flex-flow: row nowrap;
        }
        .bottons div {
            width: 100px;
            color: #000;
            background-color: rgba(0, 0, 0, 0.1);
            border: 1px solid white;
            border-radius: 3px;
            margin-left: 1px;
            cursor: pointer;
        }
        .bottons div:nth-child(1) {
            margin-left: 0;
        }
        .bottons > .bottonactive {
            background-color: white;
            border: 1px solid #999;
            color: #0d43fa;
        }
        .page {
            width: 98%;
            margin: 0 auto;
        }
        .page1 {
            display: block;
        }
        .page2 {
            display: none;
        }
        /*督办详情*/

        .top {
            width: 100%;
            background-color: rgba(0, 0, 0, 0.03);
            margin-top: 10px;
        }
        .top_div div {
            display: inline-block;
            width: 120px;
            height: 30px;
            line-height: 30px;
            text-align: left;
            color: #000;
            vertical-align: center;
        }
        .top_div2{
            line-height: 30px;
            display: flex;
            flex-flow: row nowrap;
            text-align: left;
        }
        .top_div2_title{
            display: inline-block;
            width: 120px;
            height: 30px;
            line-height: 30px;
            text-align: left;
            color: #000;
            padding: 0 10px;
            vertical-align: center;
        }
        .top_div2_download{
            flex: 1;
        }
        .download_text div{
            display: inline-block;
        }
        .top_div2_download  .download_text{
            margin-bottom: 10px;
        }
        .top_div div:nth-child(1) {
            padding: 0 10px;
        }
        .top .download_botton {
            width: 60px;
            height: 25px;
            line-height: 25px;
            text-align: center;
            color: white;
            background-color: #0e84ff;
            border-radius: 5px;
            margin-left: 10px;
            cursor: pointer;
        }
        /* 排名 */
        .ranking {
            width: 100%;
            border: 1px solid #999;
            border-radius: 5px;
            margin-top: 15px;
        }
        .ranking_title {
            width: 100%;
            height: 40px;
            line-height: 40px;
            text-align: left;
            border-bottom: 1px solid #999;
            padding: 0 10px;
        }
        .ranking_table {
            width: 90%;
            margin: 0 auto;
            margin-bottom: 30px;
        }
        .table_tr {
            width: 100%;
            height: 30px;
            line-height: 30px;
            text-align: center;
            display: flex;
            flex-flow: row nowrap;
            border-bottom: 1px solid #999;
        }
        .thetable_tr {
            width: 90%;
            margin: 0 auto;
            height: 40px;
            line-height: 40px;
            text-align: center;
            display: flex;
            flex-flow: row nowrap;
            border-bottom: 1px solid #999;
        }
        .thetable_th {
            flex: 1;
            color: #666;
        }
        .table_td {
            flex: 1;
            color: #333;
        }
        /* 汇总 */
        .summary {
            margin-top: 30px;
        }
        .summary_title {
            display: flex;
            flex-flow: row nowrap;
            text-align: left;
            padding: 0 20px;
        }
        .summary_title_1{
            height: 40px;
            line-height: 40px;
        }
        .summary_title_2{
            width: 500px;
            margin-left: 30px;
        }
        .summary_div {
            height: 40px;
            line-height: 40px;
            display: flex;
            flex-flow: row nowrap;
            text-align: left;
            padding: 0 20px;
        }
        .summary_div_text1 {
            width: 110px;
        }
        .summary_div_text2 {
            flex: 1;
        }
        .summary_div_file{
            width: 100%;
            position: relative;
        }
        .summary_div_file .summary_div_file_text1{
            width: 110px;
            height: 40px;
            line-height: 40px;
            text-align: left;
            padding: 0 20px;
            position: absolute;
            top: 0;
            left: 0;
        }
        .summary_div_file_text2{
            margin-left: 150px;
        }
        .summary_div_last {
            display: flex;
            flex-flow: row nowrap;
            justify-content: flex-start;
            margin-top: 20px;
            align-items: center;
        }
        .summary_div_last button {
            width: 100px;
            height: 30px;
            line-height: 30px;
            text-align: center;
            color: #333;
            background-color: #999;
            border-radius: 5px;
            margin-left: 20px;
            border: none;
        }
        .summary_div_last button:nth-child(1){
            cursor: not-allowed;
        }
        .upload_file {
            display: flex;
            flex-flow: row nowrap;
            align-items: center;
        }
        /*.upload_file div {*/
        /*    width: 100px;*/
        /*    height: 30px;*/
        /*    line-height: 30px;*/
        /*    text-align: center;*/
        /*    color: #333;*/
        /*    background-color: #999;*/
        /*    border-radius: 5px;*/
        /*    margin-left: 10px;*/
        /*}*/
        #openFileshow{
            width: 150px;
            height: 30px;
            line-height: 30px;
            font-size: 12px;
        }
        /* 记录 */
        .record{
            padding-bottom: 10px;
        }
        .record_caption {
            width: 500px;
            height: 60px;
            margin: 15px auto;
            display: flex;
            flex-flow: row nowrap;
        }
        .record_hr {
            width: 130px;
            height: 4px;
            background-color: #333;
            margin-top: 28px;
        }
        .caption_text {
            width: 240px;
            height: 60px;
            line-height: 60px;
            font-size: 25px;
            text-align: center;
            color: #333;
            font-weight: 500;
        }
        .allrecord{
            width: 100%;
        }
        .record {
            width: 100%;
            background-color: rgba(0, 0, 0, 0.03);
            margin-top: 20px;
        }
        .record_title {
            height: 40px;
            line-height: 40px;
            display: flex;
            flex-flow: row nowrap;
            text-align: left;
            background-color: rgba(0, 0, 0, 0.1);
            padding: 0 20px;
            margin-bottom: 20px;
        }
        .record_div {
            height: 40px;
            line-height: 20px;
            display: flex;
            flex-flow: row nowrap;
            text-align: left;
            padding: 0 20px;
        }
        .record_div2 {
            line-height: 20px;
            display: flex;
            flex-flow: row nowrap;
            text-align: left;
            padding: 0 20px;
        }
        .record_text1 {
            width: 110px;
        }
        .record_text2 {
            flex: 1;
        }
        .record_text3 {
            flex: 1;
            line-height: 20px;
            white-space: normal;
            word-break: break-all;
            word-wrap: break-word;
        }
        .record_text3 .download_text{
            margin-bottom: 10px;
        }
        .record_text3 .download_botton {
            display: inline-block;
            width: 60px;
            height: 25px;
            line-height: 25px;
            text-align: center;
            color: white;
            background-color: #0e84ff;
            border-radius: 5px;
            margin-left: 20px;
            cursor: pointer;
        }
        /*流程*/
        .process {
            width: 95%;
            border: 1px solid #666;
            box-shadow: 1px 1px 1px #999;
            border-radius: 5px;
            position: relative;
            margin-top: 20px;
        }
        #triangle-up {
            width: 20px;
            height: 20px;
            transform: rotate(45deg);
            border: 2px solid #666;
            position: absolute;
            top: -10px;
            left: 200px;
            z-index: 1;
        }
        .process_info {
            width: 100%;
            background-color: white;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 999;
        }
        .process_info_title {
            color: #000;
            height: 40px;
            line-height: 40px;
            font-size: 20px;
            padding: 0 15px;
            margin-bottom: 10px;
        }
        .process_info_text {
            width: 100%;
            color: #666;
            height: 30px;
            padding: 0 15px;
            display: flex;
            flex-flow: row nowrap;
            margin-top: 10px;
        }
        .process_info_text div:nth-child(1){
            width: 200px;
            font-size: 16px;
            line-height: 15px;
        }
        .process_info_text div:nth-child(2){
            flex: 1;
            font-size: 12px;
            line-height: 15px;
        }
        .download_botton:hover {
            opacity: 0.8;
        }
        .page3{
            display: none;
            padding-top: 50px;
        }
        .page4{
            display: none;
            padding: 0 30px;
            padding-top: 20px;
        }
        .page4_table{
            overflow-x: auto;
            border-collapse: collapse;
        }
        .page4_table_header{
            display: flex;
            flex-flow: row nowrap;
            justify-content: flex-start;
            border-collapse: collapse;
        }
        .page4_table_th{
            width: 150px;
            height: 50px;
            line-height: 50px;
            font-size: 20px;
            font-weight: 500;
            text-align: center;
            border: 1px solid rgba(239, 243, 248,0.5);
            background-color: rgba(239, 243, 245,1);
        }
        .page4_table_tr{
            display: flex;
            flex-flow: row nowrap;
            justify-content: flex-start;
            border-collapse: collapse;
        }
        .page4_table_td{
            width: 150px;
            height: 40px;
            line-height: 40px;
            font-size: 20px;
            font-weight: 300;
            text-align: center;
            border: 1px solid rgba(239, 243, 248,0.5);
        }
        .page4_table_tr:nth-child(n) .page4_table_td{
            background-color: transparent;
        }
        .page4_table_tr:nth-child(2n) .page4_table_td{
            background-color: rgba(247, 247, 247,1);
        }
    </style>
</head>
<body>


<div class="bottons">
    <div class="thebotton bottonactive">督办详情</div>
    <div class="thebotton">督察流程记录</div>
    <div class="thebotton">子事项列表</div>
    <div class="thebotton">督察统计</div>
</div>
<div class="page page1">

    <input id="specialTask_taskMainId" type="hidden" value="${specialTask.taskMainId}" />
    <input id="specialTask_type" type="hidden" value="${specialTask.type}" />
    <input id="specialTask_evaluations" type="hidden" value="${specialTask.evaluations}" />
    <input id="mainTask_mainResult" type="hidden" value="${specialTask.feedbacks}" />
    <input id="specialTask_timeRound" type="hidden" value="${specialTask.timeRound}" />
    <input id="specialTask_sysId" type="hidden" value="${ specialTask.sysId}" />
    <input id="specialTask_pagetype" type="hidden" value="${pageType}" />
    <div class="top">
        <div class="top_div">
            <div>办理时限：</div>
            <div>${specialTask.roundLimit}</div>
            <div style="margin-left: 50px">反馈轮次：</div>
            <div>${specialTask.timeRound}</div>
        </div>
        <div class="top_div">
            <div>办理情况：</div>
            <div id="specialTask_type_div" style="color: #666"></div>
        </div>
        <div class="top_div">
            <div>办结评价：</div>
            <div id="specialTask_evaluations_div"></div>
        </div>
        <div class="top_div">
            <div>我的反馈：</div>
            <div id="mainTask_mainResult_div" style="width: 300px"></div>
        </div>
<%--        <div class="top_div2">--%>
<%--            <div class="top_div2_title">附件下载：</div>--%>
<%--            <div class="top_div2_download">--%>
<%--                <div class="download_text">--%>
<%--                    <a href="javascript:;">1111</a><div class="download_botton">下载</div>--%>
<%--                </div>--%>
<%--                <div class="download_text">--%>
<%--                    <a href="javascript:;">1111</a><div class="download_botton">下载</div>--%>
<%--                </div>--%>
<%--            </div>--%>
<%--        </div>--%>
    </div>
    <!-- 排名 -->
    <div class="ranking">
        <div class="ranking_title">承办单位排名情况</div>
        <div class="thetable_tr">
            <div class="thetable_th">承办单位</div>
            <div class="thetable_th">评价</div>
        </div>
        <div class="ranking_table" id="example2">
        </div>
    </div>
    <!-- 汇总情况 -->
    <div class="summary">
        <div class="summary_title">
            <div class="summary_title_1">办理汇总情况：</div>
            <textarea  class="summary_title_2" cols="2" id="summarySituation"></textarea>
        </div>
        <div class="summary_div">
            <div class="summary_div_text1">办结评价：</div>
            <div class="summary_div_text2"  style="margin-left: 20px">
                <label for="good">
                    <input id="good" name="summary" value="1" type="radio" /> 好
                </label>
                <label for="middle" style="margin-left: 20px">
                    <input id="middle" name="summary" value="2" type="radio" /> 中
                </label>
                <label for="bad" style="margin-left: 20px">
                    <input id="bad" name="summary" value="3" type="radio" /> 差
                </label>
            </div>
        </div>
        <div class="summary_div_file">
            <div class="summary_div_file_text1">附件上传：</div>
            <div class="summary_div_file_text2 upload_file" id="togetFile">
    <%--                <input id="openFileshow" type="text" placeholder="选择附件" />--%>
    <%--                <input id="openFile" type="file" style="display: none"   multiple="multiple"/>--%>
    <%--                <div id="togetFile"  class="openFile" style="background-color: #0066ff;color: white">选择文件</div>--%>
    <%--                <div style="background-color: #0066ff;color: white">确认上传</div>--%>
            </div>
        </div>
        <div class="summary_div_last">
            <button id="determineOver" disabled="disabled">确认办结</button>
            <button style="background-color: #f1a02f;color: white"  id="determineNoOver">返回重办</button>
        </div>
    </div>
    <!-- 记录 -->
    <div class="record_caption">
        <div class="record_hr"></div>
        <div class="caption_text">本轮督办反馈记录</div>
        <div class="record_hr"></div>
    </div>
    <div class="allrecord"></div>
</div>
<div class="page page2">
    <!-- 流程记录 -->
    <div class="process">
        <div id="triangle-up"></div>
        <div class="process_info">
            <div class="process_info_title"> </div>
        </div>
    </div>
</div>
<div class="page page3">
    <div class="row">
        <div class="col-xs-12">
            <!-- PAGE CONTENT BEGINS -->
            <!-- jqGrid表格 -->
            <table id="gridTable"></table>
            <!-- jqGrid工具类 -->
            <div id="gridPager"></div>
            <!-- 查询对话框 -->
            <div style="display: none;">
                <div class="row" id="queryDialog"></div>
            </div>
            <!-- PAGE CONTENT ENDS -->
        </div><!-- /.col -->
    </div>
</div>
<div class="page page4">
    <div class="page4_row row">
        <div class="page4_table">
            <div class="page4_table_header">

            </div>
            <div class="page4_table_body">

            </div>
        </div>
    </div>
</div>

<form:form col-sm-offset-1mmandName="mainTask" cssClass="form-horizontal" role="form" onsubmit="return false;" enctype="multipart/form-data" id="updateForm" action="/taskMain/createTask/" style="display:none">
    <h3 class="tit text-center">任务详情</h3>
    <div class="form-group">
        <div>
            <label class="col-sm-2 control-label">任务名称:</label>
            <div class="col-sm-9">
                <input class="form-control"  value="${mainTask.mainName}"  readonly>
            </div>
        </div>
    </div>
    <div class="form-group">
        <div>
            <label class="col-sm-2 control-label">任务内容:</label>
            <div class="col-sm-9">
                <textarea rows="4" class="form-control"  placeholder="请输入内容" readonly>${mainTask.content}</textarea>
            </div>
        </div>
    </div>
    <%--<div class="form-group">
        <div>
            <label class="col-sm-2 control-label">任务反馈:</label>
            <div class="col-sm-9">
                <textarea rows="4" class="form-control feedback"  placeholder="请输入内容"></textarea>
            </div>
        </div>
    </div>
    <div class="form-group">
        <div class="form-group">
            <div>
                <label class="col-sm-1 col-sm-offset-1 control-label">反馈附件:</label>
                    &lt;%&ndash;<div class="col-sm-7 pos-rel">&ndash;%&gt;
                <div class="col-sm-9">
                    <div id="uploader"></div>
                        &lt;%&ndash;<input type="file" class="form-control" id="fileupload">&ndash;%&gt;
                </div>
                    &lt;%&ndash;<div class="col-sm-2">&ndash;%&gt;
                    &lt;%&ndash;<button class="btn btn-info" onclick="uploadFile(this,'file','fileName')">&ndash;%&gt;
                    &lt;%&ndash;<span class="glyphicon glyphicon-open"></span>上传附件&ndash;%&gt;
                    &lt;%&ndash;</button>&ndash;%&gt;
                    &lt;%&ndash;</div>&ndash;%&gt;
                &lt;%&ndash;<input type="hidden" id="recipientId" value="${}">&ndash;%&gt;
            </div>
        </div>
    </div>
    <div class="form-group">
        <div>
            <label class="col-sm-2 control-label">任务评价:</label>
            <div class="col-sm-1">
                <select class="form-control text-center" style="text-align-last: center"></select>
            </div>
        </div>
    </div>--%>
    <div class="form-group">
        <label class="col-sm-2 control-label">承办单位:</label>
        <div class="">
            <ol id='example' class="col-sm-offset-2 col-sm-9 list-group"></ol>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-9">
            <button class="btn-success btn-sm confirm">确定</button>
        </div>
    </div>
    <div id="sysId" class="hidden">${mainTask.sysId}</div>
    <%--当前主任务ID--%>
    <div id="taskMainId" class="hidden"></div>

    <%--
        <div id="sepcaiTaskId" class="hidden">${specialTask.sysId}</div>
    --%>
</form:form>

<%--多选上传--%>
<script src="<s:url value="/assets/js/dist/easyUploader.jq.js"></s:url>"></script>
<script src="<s:url value="/assets/js/Sortable.min.js"></s:url>"></script>
<script src="<s:url value="/assets/js/own.js"></s:url>"></script>
<%@ include file="/WEB-INF/views/include/footer.jsp" %>
<%-- 表格格式化--%>
<script>
    function lastIndexFormatter(data) {
        return data.substring(0,data.length-1)
    }

    function categoryIdFormatter(data) {
        switch (data){
            case '1':
                return '牵头';
                break;
            case '2':
                return '协办';
                break;
            default:
                return '未知';
        }
    }
    function timeRoundFormatter(data) {
        return "第"+ data + "轮"
    }

    function typeFormatter(data) {
        switch(data) {
            case '0':
                return '待签收';
                break;
            case '1':
                return '待反馈';
                break;
            case '2':
                return '已反馈';
                break;
            case '3':
                return '退回重办';
                break;
            case '4':
                return '完成';
                break;
            case '5':
                return '已签收';
                break;
            default:
                return '未知';
        }
    }
    function overdueDayFormatter(data) {
        data = parseInt(data)
        if(data>0){
            return parseInt(data)+"天"
        }else {
            return ""
        }
    }

    function feedbackBtnFormatter   (value, grid, rows, state) {
        grid.colModel.title=false
        return "<div style='color: #049CE6;display: flex;justify-content: center'>" +
            "<div style='width: 60px;cursor: pointer;border-right:1px solid #049CE6;' title='反馈汇总' id='feedbackBtn1'>反馈汇总</div>" +
            "<div style='width: 40px;cursor: pointer' title='查看' id='feedbackBtn'>查看</div>" +
            "<div style='border-left:1px solid #049CE6;width: 40px;cursor: pointer'title='删除' class='delTask'>删除</div>" +
            "<div style='width: 40px;cursor: pointer;border-left:1px solid #049CE6;' class='urge' title='催办'>催办</div>" +
            "<div style='width: 40px;cursor: pointer;border-left:1px solid #049CE6;' class='modify' title='修改'>修改</div>" +
            "</div>";
    }
</script>
<%--page3表格--%>
<script>
    // 基本路径
    var baseUrl = "<s:url value="/taskMain/query2/"></s:url>"
    // jqgrid的表格高度
    var height = 320;
    // jqgrid表格行头的中文
    var colNames = ['','子事项','责任单位',"单位类型","任务时限", "分数","任务轮次","任务状态","逾期天数","操作"];
    var colModel = [
        {name: 'sysId', width: 60, hidden: true, key: true},
        {name: 'taskSubName', index: 'taskSubName', width: 600, editable: true},
        {name: 'deptName', index: 'deptName', width: 150, editable: true,formatter:lastIndexFormatter},
        {name: 'unitType', index: 'unitType', width: 100, editable: true,formatter:categoryIdFormatter},
        {name: 'timeLimit', index: 'timeLimit', width: 100, editable: true, },
        {name: 'score', index: 'score', width: 100, editable: true, },
        {name: 'timeRound', index: 'timeRound', width: 100, editable: true,formatter:timeRoundFormatter},
        {name: 'type', index: 'type', width: 100, editable: true,formatter:typeFormatter},
        {name: 'overdueDay', index: 'overdueDay', width: 150, editable:true,formatter:overdueDayFormatter},
        {name : 'cz', width : 250, align : "center", formatter:feedbackBtnFormatter}
    ];
    // jqgrid的具体执行方法
    var rowIds;
    var userList;
    var type;
    var specialTask_taskMainId = document.getElementById("specialTask_taskMainId").value

    jqgrid({
        gridTableId: "#gridTable",
        gridPagerId: "#gridPager",//20191126100000000278
        postData:{'taskMainId':specialTask_taskMainId},
        autoScroll: false,
        shrinkToFit: true,
        multiselect:false,
        rownumbers: true,
        onSelectRow: function (rowid, status) {
            rowIds = rowid
            //选择当前的行
            rowids = rowid
            var selectedRowValue = $("#gridTable").jqGrid('getRowData', rowid);
            var types = selectedRowValue.type;//获取任务状态
            //
        },
        ondblClickRow:function (rowid) {
            /**
             * 打开二级页面
             */
            window.parent.openapp("/taskMain/unitDetail/"+rowid,rowid,"任务详情");
        },
        loadComplete:function (data) {
            var ids = $("#gridTable").jqGrid("getDataIDs");
            var rowDatas = $("#gridTable").jqGrid("getRowData");//获取所有行的数据
            for (var i = 0; i<rowDatas.length;i++){
                if (data.rows[i].type == 2){
                    $("#"+ids[i]+ " td").css("background","yellow"); //已反馈
                };
                if (data.rows[i].overdueDay){
                    $("#"+ids[i]+ " td").css("color","red"); //逾期
                }
            }
        },
    });

    //点击开二级页面
    $(document).on("click","#feedbackBtn1",function(){
        parent.openapp("/taskMain/collect/"+rowIds,rowIds,"反馈汇总");
    });
    $(document).on("click","#feedbackBtn",function(){
        parent.openapp("/taskMain/unitDetail/"+rowIds,rowIds,"任务详情");
    });
    //    催办
    $(document).on("click",".urge",function () {
        $.get("/taskMain/urgeModel/"+rowIds,function (data) {
            userList = data;
            var html = "";
            for (var i = 0; i < data.length;i++){
                if (data[i].name == undefined) {
                    data[i]['name'] = ''
                }
                if(data[i].mobile == undefined) {
                    data[i]['mobile'] = ''
                }
                html += " <div class=\"form-group clearfix\">\n" +
                    "                        <label class=\"control-label col-sm-2 text-right\">姓名</label>\n" +
                    "                        <div class=\"col-sm-9\">\n" +
                    "                            <input type=\"text\" class=\"Modelname form-control\" readonly value='"+data[i].name+"'>\n" +
                    "                        </div>\n" +
                    "                    </div>\n" +
                    "                    <div class=\"form-group clearfix\">\n" +
                    "                        <label class=\"control-label col-sm-2 text-right\">电话</label>\n" +
                    "                        <div class=\"col-sm-9\">\n" +
                    "                            <input type=\"text\" class=\"Modelphone form-control\" readonly value='"+data[i].mobile+"'>\n" +
                    "                        </div>\n" +
                    "                    </div>"
            }

            $(".information").html(html);
        });
        $('#UrgeModel').modal('show'); //显示
    });

    $("#UrgeModel select").change(function () {
        $("#UrgeModel textarea").val( $(this).val());
    })

    $(".UrgeSure").click(function () {
        failure(".UrgeSure",1)
        type = $("input[name='type']:checked").val();
        if (!type){
            type = 0;
        }
        var datas = {
            taskUnitId: rowIds,
            content: $("#UrgeModel textarea").val(),
            userList:userList,
            type:type
        }
        var jsonDatas = JSON.stringify(datas);
        $.ajax({
            url:'/taskMain/saveHasten/',
            type:'POST',
            contentType: 'application/json; charset=UTF-8',
            async:false,
            dataType:'json',
            data:jsonDatas,
            success: function (data) {
                if (data.code == "200") {
                    alert("催办成功");
                    $("#UrgeModel textarea").val("");
                    $("input[name='type']").removeAttr("checked");
                } else {
                    alert("催办失败");
                }
                failure(".UrgeSure",0)
            }
        })
    })
    //审批
    $(document).on("click",".approval",function () {
        var  sysId = $(".taskMain").attr("taskMain")
        $('#approval').modal('show'); //显示
        $.get("/taskMain/approve/"+sysId,function (data) {
            $(".Modelcontent").val(data.content);
            $(".mainName").val(data.mainName);
            $(".sysId").val(data.sysId);

        })
    });
    $(".addApproval").click(function () {
        var datas = {
            status:$("[name='isApproval']:checked").val(),
            content:$(".information1 .content").val(),
            taskMainId:$(".sysId").val()
        }
        if (!datas.status){
            return alert("请选择是否通过 ")
        }
        $.post("/taskMain/approve/",datas,function (data) {
            if (data.code==200) {
                datas.status == 2 ? alert("通过审批") : alert("不通过审批")
                open(location, '_self').close();
            }else {
                alert("审批失败");
            }
        })
    })

    //攻坚反馈 takefeedback
    $(".takefeedback").click(function() {
        failure("takefeedback",0)
        var datas ={
            mainResult:$("textarea[name='mainResult']").val() ,
            mainResultFile:$("input[name=file]").val(),
            sysId:$(".taskMain").attr("taskMain"),
            mainResultFileName:$("input[name=fileName]").val()
        };
        $.ajax({
            url:"/taskMain/saveMainResult",
            type:"post",
            data:datas,
            success:function (data) {
                if(data.code == "200"){
                    alert(data.message);
                    setTimeout(function () {
                        open(location, '_self').close();
                    },50)
                }else if(data.code == "500"){
                    alert(data.message);
                }
                failure("takefeedback",1)
            }
        })
    })
    //单位反馈
    $(".takefeedbackWd").click(function() {
        failure(".takefeedbackWd",1)
        var datas ={
            mainResult:$("textarea[name='mainResult']").val() ,
            mainResultFile:$("input[name=file]").val(),
            sysId:$(".taskMain").attr("taskMain"),
            mainResultFileName:$("input[name=fileName]").val()
        }
        /* var datas ={
             content:$("textarea[name='mainResult']").val() ,
             file:$("input[name=file]").val(),
             taskMainId:$(".taskMain").attr("taskMain"),
             fileName:$("input[name=fileName]").val()
         }*/
        $.ajax({
            // url:"/taskUnit/saveMainResult",
            url:"/taskUnit/saveDuBanBackInfo",
            type:"post",
            data:datas,
            success:function (data) {
                if(data.code == "200"){
                    alert(data.message);
                    setTimeout(function () {
                        open(location, '_self').close();
                    },50)
                }else if(data.code == "500"){
                    alert(data.message);
                }
                failure(".takefeedbackWd",0)
            }
        })
    })
    //是否办结
    function taskTtatus(status) {
        var datas = {
            sysId:$(".taskMain").attr("taskMain"),
            status:status
        }
        $.ajax({
            url:"/taskMain/updateMainStatus/",
            type:"post",
            data:datas,
            success:function (data) {
                alert(data.message);
                setTimeout(function () {
                    open(location, '_self').close();
                },50)
            }
        })
    }
    /*修改任务*/
    $(document).on("click",".date_picker",function () {
        laydate({
            elem: this,
            min: minDate(),
        });
    });
    $(document).on("click",".modify",function () {
        $.get("/taskMain/getTaskUnit/"+rowIds,function (res) {
            $("input[name=getTimeLimit]").val(res.data.timeLimit)
            $("input[name=sysId]").val(res.data.sysId)
        })
        $("#modify").modal("show")
    })
    /*修改确认*/
    $(".confirmModify").click(function () {
        var datas = {
            timeLimit:$("input[name='getTimeLimit']").val(), //时限
            sysId:$("input[name='sysId']").val()
        }
        console.log(datas)
        $.post("/taskMain/editTaskUnit/",datas,function (data) {
            if (data.code == 200){
                alert("修改成功")
                reload("#gridTable");//重载
            }else {
                alert("修改失败");
            }
        })
    })
    //删除子事项
    $(document).on("click",".delTask",function () {
        if (confirm("是否删除")) {
            $.get("/taskMain/deleteUnit/" + rowIds, function (res) {
                if (res.code == "200") {
                    alert(res.message);
                    setTimeout(function () {
                        open(location, '_self').close();
                    }, 50)
                } else {
                    alert(res.message);
                }
            })
        }
    })
    //新增子事项
    $(".addTaskSub").click(function () {
        var $taskMainSysId = $(".taskMain").attr("taskMain");
        loadDialog({
            dialogTitle: '新增子事项',
            dialogUrl: "/taskMain/addTaskSub/"+$taskMainSysId,
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="create()">添加</button>' +
                '<button type="button" class="btn btn-default" onclick="removeLayDate()" data-dismiss="modal">关闭</button>'
        });
    })
    //新增子事项
    function create() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: "/taskMain/addTaskSub/",
            tableId: "#gridTable",
            successMessage: "保存成功",
            successTitle: '保存对话框',
            failMessage: '保存失败',
            failTitle: '消息对话框'
        });
    }
    //新增子事项单位
    $(".addTaskUnitBtn").click(function () {
        var $taskMainSysId = $(".taskMain").attr("taskMain");
        loadDialog({
            dialogTitle: '新增单位',
            dialogUrl: "/taskMain/addTaskUnit/"+$taskMainSysId,
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="createTask()">添加</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>'
        });
    })
    //新增子事项单位
    function createTask() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: "/taskMain/addTaskUnit/",
            tableId: "#gridTable",
            successMessage: "保存成功",
            successTitle: '保存对话框',
            failMessage: '保存失败',
            failTitle: '消息对话框'
        });
    }
    function minDate() {
        var now = new Date();
        return now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + (now.getDate() + 1);
    }
    $(document).ready(function (){
        $(document).on("click","#date_picker",function () {
            laydate({
                elem: "#date_picker",
                min: minDate(),
            });
        });
    })
    //bug 删除时间模态框
    function removeLayDate(){
        $("#laydate_box").remove()
    }
    //任务评价
    function evaluations() {

        var eval  = $("#task-evaluations").val();
        console.log(eval)

        var datas = {
            evaluations:eval, //评价
            sysId:$(".taskMain").attr("taskMain")
        }
        console.log(datas)
        $.post("/taskMain/submitEval",datas,function (data) {
            if (data.code == 200){
                alert("评价成功")
                reload("#gridTable");//重载
            }else {
                alert("修改失败");
            }
        })

    }
    function duchaRank() {
        var eval =$("#task-evaluations").val();//评价
        var  sysId=$(".taskMain").attr("taskMain");
        parent.openapp("/taskMain/dubanfeedback?sysId="+sysId+"&eval="+eval,"接收单位")
    }
</script>
<%--文件上传--%>
<script>
    var mainResultFile = ""
    var oldName = ""
    <%--多文件上传--%>
    var fileStr = "";//id字符串拼接
    var fileNameStr = "";//文件名字符串拼接
    var uploader = easyUploader({
        id: "togetFile",
        accept: '.jpg,.png,.doc,.docx,.pdf,.xls,.xlsx,.ppt,.pptx',
        action: '/filesUpload/uploadFiles',
        dataFormat: 'formData',
        maxCount: 10,//允许上传的个数
        maxSize: 2000,//允许上传最大的容量
        multiple: true,
        data: null,
        beforeUpload: function (file, data, args) {
        },
        onChange: function (fileList) {
        },
        onRemove: function (removedFiles, files) {
            console.log('onRemove', removedFiles);
        },
        onSuccess: function (res) {
            console.log('onSuccess', res);
                if (res.data !== undefined && res.data[0] !== undefined) {
                    //拼接文件id 和 文件名
                    $("input[name='file']").val(fileStr += res.data[0].sysid + ",");
                    $("input[name='fileName']").val(fileNameStr += res.data[0].oldName + ",");
                    mainResultFile += res.data[0].sysid + ","
                    oldName += res.data[0].oldName + ","
                }
        },
        onError: function(err) {
            console.log('onError', err);
            var determineOver = document.getElementById("determineOver")
            determineOver.onclick = function(){
               alert("请进行附件上传")
            }
        },
    });
    var determineOver = document.getElementById("determineOver");
    var determineNoOver = document.getElementById("determineNoOver");
    var specialTask_sysId = document.getElementById("specialTask_sysId").value
    window.onload = function(){
        if( document.getElementById("specialTask_type_div").innerText == "完成"){
        }else{
            determineOver.style.backgroundColor = "#0e84ff"
            determineOver.disabled = false
            determineOver.style.color = "white"
            determineOver.style.cursor = "pointer"
            determineOver.onclick = function() {
                var mainResult = $("#summarySituation").val()
                var evaluations = $("input[name='summary']").val()
                var params = {
                    mainResult: mainResult,
                    evaluations: evaluations,
                    file: mainResultFile,
                    filename: oldName,
                    specialId: specialTask_sysId,
                    status:1
                }
                $.ajax({
                    url:'/taskMain/handleTask',
                    dataType:'json',
                    type:'post',
                    contentType:'application/json',
                    data:JSON.stringify(params),
                    success:function (res) {
                        if(res.code = 200){
                            alert("办结成功!")
                            location.reload();
                        }else{
                            alert("办结失败,请输入正确办结信息!")
                        }
                    }
                });
            }
          }
        determineNoOver.onclick = function() {
                var mainResult = $("#summarySituation").val()
                var evaluations = $("input[name='summary']").val()
                var params = {
                    mainResult: mainResult,
                    evaluations: evaluations,
                    file: mainResultFile,
                    filename: oldName,
                    specialId: specialTask_sysId,
                    status:2
                }
                $.ajax({
                    url:'/taskMain/handleTask',
                    dataType:'json',
                    type:'post',
                    contentType:'application/json',
                    data:JSON.stringify(params),
                    success:function (res) {
                        if(res.code = 200){
                            alert("重办成功!")
                            location.reload();
                        }else{
                            alert("办结失败,请输入正确办结信息!")
                        }
                    }
                });
            }
    }

</script>
<%--page1上部数据--%>
<script type="text/javascript">
    var specialTask_pagetype = document.getElementById("specialTask_pagetype").value
    var bottons = document.querySelectorAll(".thebotton");
    var pages = document.querySelectorAll(".page");
    console.log(specialTask_pagetype)
    if(specialTask_pagetype == 1){
        for (let i = 0; i < pages.length; i++) {
            bottons[i].className = "thebotton";
            pages[i].style.display = "none";
        }
        bottons[1].className = "thebotton bottonactive";
        pages[1].style.display = "block";
    }else if (specialTask_pagetype == 0){
        for (let i = 0; i < pages.length; i++) {
            bottons[i].className = "thebotton";
            pages[i].style.display = "none";
        }
        bottons[0].className = "thebotton bottonactive";
        pages[0].style.display = "block";
    }else if (specialTask_pagetype == 2){
        for (let i = 0; i < pages.length; i++) {
            bottons[i].className = "thebotton";
            pages[i].style.display = "none";
        }
        bottons[2].className = "thebotton bottonactive";
        pages[2].style.display = "block";
    }
    var specialTask_type = document.getElementById("specialTask_type").value
    var specialTask_type_div = document.getElementById("specialTask_type_div")
    var specialTask_evaluations = document.getElementById("specialTask_evaluations").value
    var specialTask_evaluations_div = document.getElementById("specialTask_evaluations_div")
    var mainTask_mainResult = document.getElementById("mainTask_mainResult").value
    var mainTask_mainResult_div = document.getElementById("mainTask_mainResult_div");
    console.log("------"+mainTask_mainResult)
    if(mainTask_mainResult == null||mainTask_mainResult==""||mainTask_mainResult==undefined){
        mainTask_mainResult_div.innerText = "无"
    }else {
        mainTask_mainResult_div.innerText=mainTask_mainResult;
    }
    if(specialTask_evaluations == null||specialTask_evaluations==""||specialTask_evaluations==undefined){
        specialTask_evaluations_div.innerText = "无"
    }
    if(specialTask_type==0){
        specialTask_type_div.innerText = "待签收"
    }else if(specialTask_type==1){
        specialTask_type_div.innerText = "待反馈"
    }else if(specialTask_type==2){
        specialTask_type_div.innerText = "已反馈"
    }else if(specialTask_type==3){
        specialTask_type_div.innerText = "退回"
    }else if(specialTask_type==4){
        specialTask_type_div.innerText = "完成"
    }else if(specialTask_type==5){
        specialTask_type_div.innerText = "已签收"
    }
    if(specialTask_evaluations == 1||specialTask_evaluations=='好'){
        specialTask_evaluations_div.innerText = "好"
    }else if(specialTask_evaluations == 2||specialTask_evaluations=='中'){
        specialTask_evaluations_div.innerText = "中"
    }else if(specialTask_evaluations == 3||specialTask_evaluations=='差'){
        specialTask_evaluations_div.innerText = "差"
    }
</script>
<%--承办单位排名--%>
<script>
    function orderSort(attr) {
        return function (obj1, obj2) {
            var value1 = obj1[attr];
            var value2 = obj2[attr];
            if (!isNaN(Number(value1)) && !isNaN(Number(value2))) {
                var val1 = Number(value1);
                var val2 = Number(value2);
                value1 = val1;
                value2 = val2;
            }
            if (value1 > value2) {
                return -1;
            } else if (value1 < value2) {
                return 1;
            } else {
                return 0;
            }
        };
    }
    var specialTask_taskMainId = document.getElementById("specialTask_taskMainId").value
    var specialTask_timeRound = document.getElementById("specialTask_timeRound").value
    var params = {
        taskMainId:specialTask_taskMainId,
        timeRound:specialTask_timeRound
    }
    $.ajax({
        url:'/taskMain/dubanfeedback/getsontask',
        dataType:'json',
        type:'post',
        contentType:'application/json',
        data:JSON.stringify(params),
        success:function (res) {
            var newdata = []
            for (let i = 0; i < res.data.length; i++) {
                newdata.push({
                    id:res.data[i].deptRank,
                    name:res.data[i].deptName,
                    value:res.data[i].evaluations
                })
            }
            var paixu = "";
            for (let i = 0; i < newdata.length; i++) {
                if (newdata[i].value == "好") {
                    paixu +=
                        '<div class="table_tr">' +
                        '<div class="table_td">' +
                        newdata[i].name +
                        '</div>' +
                        '<div class="table_td" style="color:green">' +
                        newdata[i].value +
                        '</div>' +
                        '</div>';
                }
                if (newdata[i].value == "中") {
                    paixu +=
                        '<div class="table_tr">' +
                        '<div class="table_td">' +
                        newdata[i].name +
                        '</div>' +
                        '<div class="table_td" style="color:orange">' +
                        newdata[i].value +
                        '</div>' +
                        '</div>';
                }
                if (newdata[i].value == "差") {
                    paixu +=
                        '<div class="table_tr">' +
                        '<div class="table_td">' +
                        newdata[i].name +
                        '</div>' +
                        '<div class="table_td" style="color:red">' +
                        newdata[i].value +
                        '</div>' +
                        '</div>';
                }
                if (newdata[i].value == "-") {
                    paixu +=
                        '<div class="table_tr">' +
                        '<div class="table_td">' +
                        newdata[i].name +
                        '</div>' +
                        '<div class="table_td" style="color:black">' +
                        newdata[i].value +
                        '</div>' +
                        '</div>';
                }
            }
            var table = document.querySelector(".ranking_table");
            // table.innerHTML = (table.innerHTML + hao + zhong + cha+ wu).split("undefined").join("");
            table.innerHTML = (table.innerHTML + paixu).split("undefined").join("");
        }
    });
</script>
<%--督办单位反馈记录--%>
<script>
    function orderSort(attr) {
        return function (obj1, obj2) {
            var value1 = obj1[attr];
            var value2 = obj2[attr];
            if (!isNaN(Number(value1)) && !isNaN(Number(value2))) {
                var val1 = Number(value1);
                var val2 = Number(value2);
                value1 = val1;
                value2 = val2;
            }
            if (value1 > value2) {
                return -1;
            } else if (value1 < value2) {
                return 1;
            } else {
                return 0;
            }
        };
    }
    var specialTask_taskMainId = document.getElementById("specialTask_taskMainId").value
    var specialTask_timeRound = document.getElementById("specialTask_timeRound").value
    $.ajax({
        url:'/taskMain/historyDuBan?taskMainId='+specialTask_taskMainId+"&timeRound="+specialTask_timeRound,
        dataType:'json',
        type:'get',
        contentType:'application/json',
        success:function (res) {
            var html="";
            var dataArr = []
            for (let i = 0; i < res.data.length; i++) {
                dataArr.push({
                    time:res.data[i].createDate + " " + res.data[i].createTime,
                    content:res.data[i].content,
                    problem:res.data[i].problem,
                    plan:res.data[i].plan,
                    fileDto:res.data[i].fileDto,
                })
            }
            var newdata =  dataArr.sort(orderSort("time"))
            var html = ""
            for (let i = 0; i < newdata.length; i++) {
                let file_div = ""
                if(newdata[i].fileDto == ""||newdata[i].fileDto==undefined||newdata[i].fileDto==null){
                    file_div = '<div class="download_text"> 无</div>'
                }else{
                    for (let j = 0; j < newdata[i].fileDto.length; j++) {
                        file_div += '<div class="download_text"> ' +
                            '<input type="hidden" class="xiazaiwenjianid" value="'+ newdata[i].fileDto[j].fileId +'"> ' +
                            '<a href="javascript:;"  style="display: inline-block;width: 150px;"  class="xiazaiwenjianming">'+newdata[i].fileDto[j].fileName+'</a>' +
                            '<div class="download_botton xiazaiwenjiananniu">下载</div>' +
                            '</div>'
                    }
                }
                html +=  '<div class="record">'+
                             '<div class="record_title">'+
                                '<div class="record_text1">反馈时间：</div>'+
                                '<div class="record_text2">'+newdata[i].time+'</div>'+
                            '</div>'+
                            '<div class="record_div">'+
                                '<div class="record_text1">办理情况：</div>'+
                                 '<div class="record_text3">'+newdata[i].content+'</div>'+
                           '</div>'+
                             '<div class="record_div">'+
                                '<div class="record_text1">存在问题：</div>'+
                                '<div class="record_text3">'+newdata[i].problem+'</div>'+
                            '</div>'+
                            '<div class="record_div">'+
                                 '<div class="record_text1">下步计划：</div>'+
                                 '<div class="record_text3">'+newdata[i].plan+'</div>'+
                            '</div>'+
                            '<div class="record_div2">'+
                                '<div class="record_text1">附件下载：</div>'+
                                '<div class="record_text3">'+
                                    file_div +
                                '</div>'+
                            '</div>'+
                         '</div>'
            }
            var allrecord = document.querySelector(".allrecord")
            allrecord.innerHTML = html
            var xiazaiwenjianid = document.querySelectorAll(".xiazaiwenjianid")
            var xiazaiwenjianming = document.querySelectorAll(".xiazaiwenjianming")
            var xiazaiwenjiananniu = document.querySelectorAll(".xiazaiwenjiananniu")
            for (let i = 0; i < xiazaiwenjiananniu.length; i++) {
                xiazaiwenjiananniu[i].onclick = function(){
                    window.open('/filesUpload/download?id='+xiazaiwenjianid[i].value+'&name='+xiazaiwenjianming[i].innerText)
                }
            }

        }
    });
</script>
<%--督查流程记录--%>
<script>
    function orderSort(attr) {
        return function (obj1, obj2) {
            var value1 = obj1[attr];
            var value2 = obj2[attr];
            if (!isNaN(Number(value1)) && !isNaN(Number(value2))) {
                var val1 = Number(value1);
                var val2 = Number(value2);
                value1 = val1;
                value2 = val2;
            }
            if (value1 > value2) {
                return -1;
            } else if (value1 < value2) {
                return 1;
            } else {
                return 0;
            }
        };
    }
    var specialTask_sysId = document.getElementById("specialTask_sysId").value
    $.ajax({
        url:'/taskMain/liuchengLog?taskUnitId='+specialTask_sysId,
        dataType:'json',
        type:'get',
        contentType:'application/json',
        success:function (res) {
            var process_info = document.querySelector(".process_info")
            var process_info_title = document.querySelector(".process_info_title")
            process_info_title.innerHTML = "共"+ res.data.length + "条督察记录"
            let process_html = ""
            for (let i = 0; i <  res.data.length; i++) {
                process_html += "<div class=\"process_info_text\">"+
                    "<div>"+ res.data[i].updDate + " "+ res.data[i].createTime+"</div>"+
                    "<div>"+res.data[i].content+"</div>"+
                "</div>"
            }
            process_info.innerHTML += process_html
        }
    });
</script>
<script type="text/javascript">
    var bottons = document.querySelectorAll(".thebotton");
    var pages = document.querySelectorAll(".page");
    for (let i = 0; i < bottons.length; i++) {
        bottons[i].onclick = function () {
            for (let j = 0; j < bottons.length; j++) {
                bottons[j].className = "thebotton";
                pages[j].style.display = "none";
            }
            bottons[i].className = "thebotton bottonactive";
            pages[i].style.display = "block";
        };
    }

    var openFile = document.querySelector(".openFile");
    var openFileId = document.querySelector("#openFile");
    var openFileshow = document.querySelector("#openFileshow");
    openFile.onclick = function () {
        openFileId.click();
    };
    openFileId.onchange = function (e) {
        var name = "";
        for (let i = 0; i < this.files.length; i++) {
            name += this.files[i].name + "，"
        }
        openFileshow.value = name
    };
</script>

<script type="text/javascript">
    $(function  () {
        $.ajax({
            url:'/appAdmin/scoreLevelList',
            dataType:'json',
            type:'post',
            contentType:'application/json',
            data:'{}',
            success:function (data) {
                data.data.forEach(function (item) {
                    $("select").append("<option value=\""+ item.sysId +"\">"+item.name +"</option>")
                })
            }
        });
        var taskMainId = {taskMainId: $('#sysId').text()};
        // $.ajax({
        //     url:'/taskMain/dubanfeedback/getsontask',
        //     dataType:'json',
        //     type:'post',
        //     contentType:'application/json',
        //     data:JSON.stringify(taskMainId),
        //     success:function (data) {
        //         $("#taskMainId").html(data.data[0].taskMainId)
        //         data.data.forEach(function (item) {
        //             $("#example").append(" <li data-rank-id="+item.sysId+ "  class=\"list-group-item\" deptId="+ item.deptId +" ><span class='deptname-js' style=\"font-size: 20px\">"+ item.deptName +" </span>  <span style=\"font-size: 20px\">       -->评价： "+ item.evaluations +" </span> </li>")
        //         })
        //     }
        // })
    });
    new Sortable(example2, {
        animation: 150,
        group: 'shared', // set both lists to same group
        // 元素被选中
        onChoose: function (/**Event*/evt) {
            evt.oldIndex;  // element index within parent
        },

        // 元素未被选中的时候（从选中到未选中）
        onUnchoose: function(/**Event*/evt) {
            // same properties as onEnd
        },

        // 开始拖拽的时候
        onStart: function (/**Event*/evt) {
            evt.oldIndex;  // element index within parent
        },

        // 结束拖拽
        onEnd: function (/**Event*/evt) {
            var itemEl = evt.item;  // dragged HTMLElement
            evt.to;    // target list
            evt.from;  // previous list
            evt.oldIndex;  // element's old index within old parent
            evt.newIndex;  // element's new index within new parent
            evt.clone // the clone element
            evt.pullMode;  // when item is in another sortable: `"clone"` if cloning, `true` if moving
        },

        // 元素从一个列表拖拽到另一个列表
        onAdd: function (/**Event*/evt) {
            // same properties as onEnd
        },

        // 列表内元素顺序更新的时候触发
        onUpdate: function (/**Event*/evt) {
            // same properties as onEnd
        },

        // 列表的任何更改都会触发
        onSort: function (/**Event*/evt) {
            // same properties as onEnd
        },

        // 元素从列表中移除进入另一个列表
        onRemove: function (/**Event*/evt) {
            // same properties as onEnd
        },

        // 试图拖拽一个filtered的元素
        onFilter: function (/**Event*/evt) {
            var itemEl = evt.item;  // HTMLElement receiving the `mousedown|tapstart` event.
        },

        // 拖拽移动的时候
        onMove: function (/**Event*/evt, /**Event*/originalEvent) {

            evt.dragged; // dragged HTMLElement
            evt.draggedRect; // DOMRect {left, top, right, bottom}
            evt.related; // HTMLElement on which have guided
            evt.relatedRect; // DOMRect
            evt.willInsertAfter; // Boolean that is true if Sortable will insert drag element after target by default
            originalEvent.clientY; // mouse position
            // console.log(originalEvent,evt)
        },

        // clone一个元素的时候触发
        onClone: function (/**Event*/evt) {

            var origEl = evt.item;
            var cloneEl = evt.clone;
        },

        // 拖拽元素改变位置的时候
        onChange: function(/**Event*/evt) {
            // console.log(evt.newIndex )
        }
    });
    $('.confirm').click(function () {
        var sysId = $('#sysId').text();         //获取sysId值
        var sort = [];                           //承办单位
        $('#example').find('li').each(function() {
            sort.push({
                deptId:$(this).attr('deptId'),sysId:$(this).attr("data-rank-id"),deptName:$(this).children(".deptname-js").text(),deptRank:$(this).index()+1
            })
        });
        var taskMainId =$('#sysId').text();   //主任id
        //  var evaluation = $('select').val();          //好评
        //  var feedback = $('.feedback').val()         //获取反馈内容
        //  var sptaskId = $("#sepcaiTaskId").text();
        var datas = {
            /*specialId:sptaskId,
            mainResult:feedback,                        //反馈内容
            evaMainTask:evaluation,  */                    //好评
            json:JSON.stringify(sort),                         //承办单位
            sysId: taskMainId,                 //主任务ID
            /* mainResultFile: fileStr,                       //附件
             mainResultFileName: fileNameStr */              //附件名
        }
        //提交
        /* $.post("/taskMain/submintDbFeedBack",datas,function (results) {
             if (data.code == 200) {
                 alert(data.message);
                 setTimeout(function () {
                     //刷新当前页面
                     open(location, '_self').close();
                 }, 50)
             } else {
                 alert(data.message);
             }
             failure(",FeedbackConfirm", 0)
         })*/

        //提交
        $.ajax({
            url:'/taskMain/rankDepts',
            dataType:'json',
            type:'post',
            contentType:'application/json',
            data:JSON.stringify(datas),
            success:function (data) {
                console.log(data);
                if(data.code ==200){
                    alert("操作成功")
                    setTimeout(function () {
                        //刷新当前页面
                        open(location, '_self').close();
                    }, 50)
                }else {
                    alert("操作失败:"+data.message);
                }
            }
        })
    })


    // [
    //   {"deptId":"","deptName":"政府办","sort":"1"},
    //   {"deptId":"","deptName":"效能办","sort":"2"},
    //   {"deptId":"","deptName":"县政委","sort":"3"},
    //   {"deptId":"","deptName":"作战室","sort":"4"}
    //   ]
</script>
<%--<script>
    &lt;%&ndash;多文件上传&ndash;%&gt;
    var fileStr = "";//id字符串拼接
    var fileNameStr = "";//文件名字符串拼接
    var uploader = easyUploader({
        id: "uploader",
        accept: '.jpg,.png,.doc,.docx,.pdf,.xls,.xlsx,.ppt,.pptx',
        action: '/filesUpload/uploadFiles',
        dataFormat: 'formData',
        maxCount: 10,//允许上传的个数
        maxSize: 2000,//允许上传最大的容量
        multiple: true,
        data: null,
        beforeUpload: function (file, data, args) {
        },
        onChange: function (fileList) {
        },
        onRemove: function (removedFiles, files) {
            console.log('onRemove', removedFiles);
        },
        onSuccess: function (res) {
            console.log('onSuccess', res);
            if (res.data !== undefined && res.data[0] !== undefined) {
                //拼接文件id 和 文件名
                fileStr += res.data[0].sysid + ",";
                fileNameStr += res.data[0].oldName + ",";
                console.log(fileStr)
                console.log(fileNameStr)
            }
        },
        onError: function (err) {
            console.log('onError', err);
        },
    });
</script>--%>

<%--督察统计--%>
<script>
    var taskMainId =$('#sysId').text();
    var page4data = {
        taskMainId: taskMainId
    }
    $.ajax({
        url:'/taskMain/getdeptRanks',
        type:'GET',
        contentType: 'application/json; charset=UTF-8',
        async:false,
        dataType:'json',
        data:page4data,
        success: function (data) {
            console.log("6666666666666666")
            console.log(data.data)
            var tableTrData = data.data.timeRound
            var tableTdData = data.data.deptEvals
            console.log(tableTdData)
            var html_th = "<div class='page4_table_th'>单位/轮次</div>"
            var html_td = ""
            for (var i = 0; i < tableTrData.length; i++) {
                html_th += "<div class='page4_table_th'>"+ tableTrData[i] +"</div>"
            }
            for (key in tableTdData) {
                var html_td_td = ""
                for (var j = 0; j < tableTdData[key].length; j++) {
                    html_td_td += "<div class='page4_table_td'>"+tableTdData[key][j].evaluations+"</div>"
                }
                html_td += "<div class='page4_table_tr'>"+
                    "<div class='page4_table_td'>"+ key +"</div>"+
                             html_td_td
                    +"</div>"
            }
            $(".page4_table_header").html(html_th)
            $(".page4_table_body").html(html_td)
        }
    })
</script>
</body>
</html>